package io.mybatis.example.springboot.controller;

import io.mybatis.common.core.DataResponse;
import io.mybatis.common.core.RowsResponse;

import io.mybatis.example.springboot.model.QrtzFiredTriggers;
import io.mybatis.example.springboot.service.QrtzFiredTriggersService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * QRTZ_FIRED_TRIGGERS - 已触发的触发器表
 *
 * @author mkj
 */
@RestController
@RequestMapping("qrtzFiredTriggerses")
public class QrtzFiredTriggersController {

  @Autowired
  private QrtzFiredTriggersService qrtzFiredTriggersService;

  @PostMapping
  public DataResponse<QrtzFiredTriggersDO> save(@RequestBody QrtzFiredTriggersDO qrtzFiredTriggers) {
    return DataResponse.ok(qrtzFiredTriggersService.save( qrtzFiredTriggers));
  }

  @GetMapping
  public RowsResponse<QrtzFiredTriggersDO> findList(@RequestBody QrtzFiredTriggersDO qrtzFiredTriggers) {
    return RowsResponse.ok(qrtzFiredTriggersService.findList( qrtzFiredTriggers));
  }

  @GetMapping(value = "/{id}")
  public DataResponse<QrtzFiredTriggersDO> findById(@PathVariable("id") Long id) {
    return DataResponse.ok(qrtzFiredTriggersService.findById(id));
  }

  @PutMapping(value = "/{id}")
  public DataResponse<QrtzFiredTriggersDO> update(@PathVariable("id") Long id, @RequestBody QrtzFiredTriggersDO qrtzFiredTriggers) {
    qrtzFiredTriggers.setId(id);
    return DataResponse.ok(qrtzFiredTriggersService.update( qrtzFiredTriggers));
  }

  @DeleteMapping(value = "/{id}")
  public DataResponse<Boolean> deleteById(@PathVariable("id") Long id) {
    return DataResponse.ok(qrtzFiredTriggersService.deleteById(id) == 1);
  }

}
